@RestController
@RequestMapping("/api/comments")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/playlist/{playlistId}")
    public ResponseEntity<List<Comment>> getCommentsByPlaylistId(@PathVariable Long playlistId) {
        List<Comment> comments = commentService.getCommentsByPlaylistId(playlistId);
        return ResponseEntity.ok(comments);
    }

    @PostMapping("/add")
    public ResponseEntity<Comment> addComment(@RequestBody CommentRequest commentRequest) {
        Long userId = commentRequest.getUserId();
        Long playlistId = commentRequest.getPlaylistId();
        String content = commentRequest.getContent();

        Comment addedComment = commentService.addComment(userId, playlistId, content);
        return ResponseEntity.ok(addedComment);
    }
}
